<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <title>Document</title>
  </head>
  <body>
    <iframe id="printIframe" src="" frameborder="0" style="display: none"></iframe>
    <script>
      let pdfSrc = '/zj/entrustList/generateEntrustPDF.exc'
      let ip = 'http://192.168.20.6:5050'
      let data = { entrustId: 'S10023_5050_16488796309630012' }
      function print() {
        $.ajax({
          url: `${ip}${pdfSrc}`,
          xhrFields: { responseType: 'arraybuffer' },
          data,
          type: 'POST',
          success: function (response) {
            var blob = new Blob([response], { type: 'application/pdf' })
            window.URL.createObjectURL(blob)
            $('#printIframe').attr('src', window.URL.createObjectURL(blob))
            setTimeout(() => {
              $('#printIframe')[0].contentWindow.print()
              window.URL.revokeObjectURL(blob)
            }, 300)
          }
        })
      }
      print()
    </script>
  </body>
</html>
